﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DigitalPlatform.Common.Event;
using DigitalPlatform.Models;
using Prism.Commands;
using Prism.Events;
using Prism.Ioc;
using Prism.Modularity;
using Prism.Mvvm;
using Unity;

namespace DigitalPlatform.ViewModels
{
    public class LoginViewModel : BindableBase
    {
        [Dependency]
        public IEventAggregator _eventAggregator { get; set; }
        public LoginViewModel()
        {
            Init();
        }

        #region init
        private void Init()
        {
            bnLogin = new DelegateCommand(bnloginc_click);
            User = new UserModel() { UserName = "admin",UserPwd = "admin" };
        }
        #endregion

        #region commandfunc
        // 点击登录事件
        public void bnloginc_click()
        {
            _ = _eventAggregator;
            if (User.UserName == "admin" && User.UserPwd == "admin")
            {
                _eventAggregator.GetEvent<Event_CloseLoginWindow>().Publish();
            }
        }


        #endregion
        #region command
        public DelegateCommand bnLogin { get; set; }

        #endregion
        #region properties
        public UserModel User { get; set; }

        #endregion

    }
}
